#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
typedef struct stu
{
    char name[20];
    int count;
}s;
int move(const void* e1, const void* e2)
{
    return ((struct stu*)e2)->count - ((struct stu*)e1)->count;
}
int main()
{
    int n;
    scanf("%d", &n);
    struct stu s[7];
    //char str[20];
    //int max=0;
    for (int i = 0;i < n;i++)
    {
        getchar();
        scanf("%s %d", s[i].name, &s[i].count);
    }
    qsort(s, n, sizeof(s[0]), move);
    printf("%s", s[0].name);
    return 0;
}